Skip to content

Add E-ink Optimizations and AI-Assisted Reading#37

Open
kkbin505 wants to merge 2 commits into
ArtifexSoftware:masterfrom
kkbin505:e-ink-support
Open

Add E-ink Optimizations and AI-Assisted Reading#37
kkbin505 wants to merge 2 commits into
ArtifexSoftware:masterfrom
kkbin505:e-ink-support

Conversation

@kkbin505
Copy link
Copy Markdown

@kkbin505 kkbin505 commented May 9, 2026

This PR adds two major feature areas to the MuPDF Android viewer:

  • E-ink screen support — disables animations and triggers full-screen refresh cycles to eliminate ghosting on e-ink panels.
  • AI-assisted reading — lets users draw a gesture on any PDF page to get a streaming AI explanation and save the result as an Atomic Note to Obsidian.

Changes

E-ink Screen Optimizations

  • ReaderView: add setAnimationsEnabled(bool) — when disabled, scroll duration drops from 400 ms to 1 ms, drag scrolling is suppressed, and fling gestures jump directly to the next/previous page instead of smooth-scrolling.
  • ReaderView: add setEinkRefreshEnabled(bool) — posts invalidate() after each page settlement to trigger a full-screen e-ink refresh cycle.
  • DocumentActivity: add a Settings button (wrench icon) to the top bar with a popup menu for toggling animations, e-ink refresh, and entering the OpenAI API key. Settings persist via SharedPreferences.

AI-Assisted Reading

File Role
AiDocumentActivity Extends DocumentActivity; hosts the Compose AI overlay without replacing the existing reader UI
IonizationOverlay Full-screen Canvas gesture layer; detects free-form draw gestures and fires a vibration + AI request on release
OpenAiClient Streams chat completions from the OpenAI API over SSE (OkHttp); system prompt produces an AI Explanation + Atomic Note (core concept / key insight / connections)
AiPanel Bottom sheet (Compose) that slides up and renders the streaming response token-by-token
AiFloatingDialog Floating card variant used in AtomReadActivity
MuPDFCore.getPageText() New method: extracts structured text from the current page via MuPDF's StructuredText API for use as AI context
SecurePreferences Stores the OpenAI API key in EncryptedSharedPreferences (AES256-GCM)
ObsidianExporter Saves AI responses as .md files under Documents/ObsidianVault/Atoms/ with #atom #atomread tags
AtomReadActivity Alternate PDF intent handler (application/pdf MIME); registered in manifest so it appears in the system "Open with" sheet
BondingView Prototype Compose component for drag-and-drop linking of atomic notes (not yet wired to main flow)

kkbin505 added 2 commits May 9, 2026 09:56
Add two major feature areas on top of the MuPDF Android viewer base.

### E-ink Screen Optimizations

- Add `setAnimationsEnabled(bool)` to ReaderView: when disabled, scroll
  duration drops from 400 ms to 1 ms and drag scrolling is suppressed,
  eliminating ghosting on e-ink panels.
- Add `setEinkRefreshEnabled(bool)` to ReaderView: posts an invalidate()
  after each page settlement to trigger a full-screen refresh cycle.
- Fling gestures now jump directly to the next/previous page instead of
  smooth-scrolling when animations are off.
- Add a Settings button (wrench icon) to the top bar with a popup menu
  for toggling animations, e-ink refresh, and setting the OpenAI API key.
  All settings are persisted via SharedPreferences.

### AI-Assisted Reading

- Add AiDocumentActivity (extends DocumentActivity) that overlays a
  Jetpack Compose UI onto the existing PDF reader without replacing it.
- Add IonizationOverlay: a full-screen Canvas gesture layer that detects
  free-form draw gestures and fires a vibration + AI request on release.
- Add OpenAiClient: streams chat completions from the OpenAI API over SSE
  using OkHttp. The system prompt produces two structured sections —
  an AI Explanation and an Atomic Note (core concept / key insight /
  connections).
- Add AiPanel: a bottom sheet built in Compose that slides up and renders
  the streaming response token-by-token in real time.
- Expose MuPDFCore.getPageText() to extract structured text from the
  current page via MuPDF's StructuredText API for use as AI context.
- Add SecurePreferences: stores the OpenAI API key in
  EncryptedSharedPreferences (AES256-GCM) so the key is never stored
  in plain text.
- Add ObsidianExporter: saves AI responses as Markdown files under
  Documents/ObsidianVault/Atoms/ with #atom #atomread tags for
  integration with Obsidian.
- Add AtomReadActivity registered as an alternate PDF intent handler
  (application/pdf MIME), combining the PDF viewer with the AI overlay.
- Add BondingView: prototype Compose component for visually linking
  atomic notes via drag-and-drop collision (not yet wired to main flow).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant